<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("components4phpfull/jtjavascript.inc.php");
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("platinumgrid/jtplatinumgrid.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class vendor_list2 extends Page
{
       public $Image4 = null;
       public $btnSearch = null;
       public $edtSearch = null;
       public $imgNext = null;
       public $imgBack = null;
       public $JSEdit = null;
       public $JSDelete = null;
       public $JTVendorList = null;
       public $imgAdd = null;
       public $Image1 = null;
       public $JTSiteTheme1 = null;
       function edtSearchJSClick($sender, $params)
       {

       ?>
       document.getElementById('edSearch').value = '';

       <?php

       }

       function imgNextJSClick($sender, $params)
       {

       ?>
       //var answer = confirm("Proceed to next step?");
	     //if(answer)
       //{
		    window.location.href = "set_template_list.php";
		   //}
       <?php

       }
       function imgNextJSMouseOut($sender, $params)
       {

       ?>
       document.images['imgNext'].src = 'image/btn_next.png';
       <?php

       }

       function imgNextJSMouseOver($sender, $params)
       {

       ?>
       document.images['imgNext'].src = 'image/btn_next2.png';
       <?php

       }

       function imgBackJSClick($sender, $params)
       {

       ?>
       window.location.href = "set_personnel_list.php";

       <?php

       }

       function imgBackJSMouseOut($sender, $params)
       {

       ?>
       document.images['imgBack'].src = 'image/btn_back1.png';
       <?php

       }

       function imgBackJSMouseOver($sender, $params)
       {

       ?>
       document.images['imgBack'].src = 'image/btn_back21.png';
       <?php

       }

       function btnNextJSClick($sender, $params)
       {

       ?>
       var answer = confirm("Proceed to next step?");
	     if(answer)
       {
		    window.location.href = "set_template_list.php";
		   }
       <?php

       }

       function imgAddJSClick($sender, $params)
       {

       ?>
       var win_height = 660;
       var win_width = 835;
       var height = window.opener.outerHeight;
       var width = window.opener.outerWidth;
       var top = Math.round((height-win_height)/2);
       var left = Math.round((width-win_width)/2);
       window.open('set_vendor_create.php','vendor_create_window','location=no,height='+win_height+',width='+win_width+',top='+top+',left='+left);
       <?php

       }


       function JTVendorListShow($sender, $params)
       {
       $search = $this->edtSearch->Text;
       $query1 = "select * from vendor_tbl where company_id='".$_SESSION['company_id']."'
       AND
       (vendor_num LIKE '%".$search."%'
       OR vendor_name LIKE '%".$search."%'
       OR address LIKE '%".$search."%'
       OR product LIKE '%".$search."%'
       OR comp_phone LIKE '%".$search."%'
       OR email LIKE '%".$search."%')";
       $result = mysql_query($query1)or die(mysql_error());

        $arr = array();
        while($row = mysql_fetch_array($result))
          {
            $vendor_id = $row['vendor_id'];
            //$vendor = "<a href=vendor_edit.php?vend_id=".$vendor_id.">".$row['vendor_num']."</a>";
            //$vendor = "<span onclick=js_edit('".$vendor_id."') style='color:blue;cursor:pointer'>".$row['vendor_num']."</span>";
            $vendor = "<span onclick=js_edit('".$vendor_id."') style='color:blue;cursor:pointer;text-decoration:underline' title='edit'>".$row['vendor_name']."</span>";
            $tools = "<img onclick=js_deleteVendor('".$vendor_id."'); src='image/delete.png' title='delete' style='cursor:pointer'>";


            $arr[] = array(
                        //'Vendor No.' => $vendor,
                        'Vendor Name' => $vendor,
                        'City' => $row['city'],
                        'Product' => $row['product'],
                        'Company Phone' => $row['comp_phone'],
                        'Email Address' => $row['email'],
                        'Tools' => $tools
                        );


          }

            $this->JTVendorList->setCellData($arr);


       }


       function vendor_list2Create($sender, $params)
       {
       //$this->imgAdd->setLink('vendor_create.php');


       }

       function imgAddJSMouseOut($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgAdd'].src="image/add_new.png"
       <?php

       }

       function imgAddJSMouseOver($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgAdd'].src="image/add_new_blue.png"
       <?php

       }

}

global $application;

global $vendor_list2;

//Creates the form
$vendor_list2=new vendor_list2($application);

//Read from resource file
$vendor_list2->loadResource(__FILE__);

//Shows the form
$vendor_list2->show();

?>